package demo03;

import java.util.Scanner;

public class Test01StringCombine {
    public static void main(String[] args) {
        int[] array = {1, 2, 3};
        System.out.println(StringCombine(array));
    }

    public static String StringCombine(int[] array) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入想要的word");
        String str = sc.next();
        String str3 = "[";
//        String str3=str2.concat(str + array[0] + "#"+str + array[1] + "#"+str + array[2] + "]");
        for (int i = 0; i < array.length; i++) {
            if (i == array.length - 1) {
                str3 = str3.concat(str + array[i] + "]");
            } else {
                str3 = str3.concat(str + array[i] + "#");
            }
        }
        return str3;
    }

    public static String StringCombine1(int[] array) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入想要的word");
        String str = sc.next();
        String str2 = "[";
        for (int i = 0; i < array.length; i++) {
            if (i == array.length - 1) {
                str2 = str2.concat(str + array[i] + "]");
            } else {
                str2 = str2.concat(str + array[i] + "#");
            }
        }
        return str2;
    }
}

